package com.cbj.db_work.service.impl;

import com.cbj.db_work.entity.GameManage;
import com.cbj.db_work.entity.Team;
import com.cbj.db_work.entity.vo.TeamVo;
import com.cbj.db_work.mapper.TeamMapper;
import com.cbj.db_work.service.TeamService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author cbj
 * @since 2021-07-01
 */
@Service
public class TeamServiceImpl extends ServiceImpl<TeamMapper, Team> implements TeamService {

    @Override
    public GameManage setDManage() {
        // 16强
        GameManage france = new GameManage("法国", null);
        GameManage bilishi = new GameManage("比利时", null);
        GameManage putaoya = new GameManage("葡萄牙", null);
        GameManage germany = new GameManage("德国", null);
        GameManage weiershi = new GameManage("威尔士", null);
        GameManage danmai = new GameManage("丹麦", null);
        GameManage yidali = new GameManage("意大利", null);
        GameManage aolidi = new GameManage("奥地利", null);
        GameManage helan = new GameManage("荷兰", null);
        GameManage jieke = new GameManage("捷克", null);
        GameManage keluodiya = new GameManage("克罗地亚", null);
        GameManage xibanya = new GameManage("西班牙", null);
        GameManage ruidian = new GameManage("瑞典", null);
        GameManage yinggelan = new GameManage("英格兰", null);
        GameManage ruishi = new GameManage("瑞士", null);
        GameManage wukelan = new GameManage("乌克兰", null);
        List<GameManage> list1 = new ArrayList<>();
        List<GameManage> list2 = new ArrayList<>();
        List<GameManage> list3 = new ArrayList<>();
        List<GameManage> list4 = new ArrayList<>();
        List<GameManage> list5 = new ArrayList<>();
        List<GameManage> list6 = new ArrayList<>();
        List<GameManage> list7 = new ArrayList<>();
        List<GameManage> list8 = new ArrayList<>();
        list1.add(weiershi);
        list1.add(danmai);
        list2.add(yidali);
        list2.add(aolidi);
        list3.add(helan);
        list3.add(jieke);
        list4.add(bilishi);
        list4.add(putaoya);
        list5.add(keluodiya);
        list5.add(xibanya);
        list6.add(france);
        list6.add(ruishi);
        list7.add(yinggelan);
        list7.add(germany);
        list8.add(ruidian);
        list8.add(wukelan);
        // 8强
        GameManage ruishi1 = new GameManage("瑞士", list6);
        GameManage danmai1 = new GameManage("丹麦", list1);
        GameManage yidali1 = new GameManage("意大利", list2);
        GameManage jieke1 = new GameManage("捷克", list3);
        GameManage bilishi1 = new GameManage("比利时", list4);
        GameManage xibanya1 = new GameManage("西班牙", list5);
        GameManage yinggelan1 = new GameManage("英格兰", list7);
        GameManage wukelan1 = new GameManage("乌克兰", list8);
        // 4强
        List<GameManage> list11 = new ArrayList<>();
        list11.add(bilishi1);
        list11.add(yidali1);
        List<GameManage> list12 = new ArrayList<>();
        list12.add(ruishi1);
        list12.add(xibanya1);
        List<GameManage> list13 = new ArrayList<>();
        list13.add(wukelan1);
        list13.add(yinggelan1);
        List<GameManage> list14 = new ArrayList<>();
        list14.add(jieke1);
        list14.add(danmai1);
        GameManage xibanya2 = new GameManage("西班牙", list12);
        GameManage yidali2 = new GameManage("意大利", list11);
        GameManage danmai2 = new GameManage("丹麦", list14);
        GameManage yinggelan2 = new GameManage("英格兰", list13);
        // 半决赛
        List<GameManage> list21 = new ArrayList<>();
        list21.add(xibanya2);
        list21.add(yidali2);
        List<GameManage> list22 = new ArrayList<>();
        list22.add(danmai2);
        list22.add(yinggelan2);
        GameManage yidali3 = new GameManage("意大利", list21);
        GameManage yinggelan3 = new GameManage("英格兰", list22);
        // 冠军
        List<GameManage> list31 = new ArrayList<>();
        list31.add(yidali3);
        list31.add(yinggelan3);
        GameManage yidali34 = new GameManage("意大利", list31);
        return yidali34;
    }

    @Override
    public boolean addTeam(TeamVo teamVo) {
        Team team = new Team();
        BeanUtils.copyProperties(teamVo,team);
        int insert = baseMapper.insert(team);
        if(insert>0)
            return true;
        return false;
    }
}
